var app = new Vue({
    el: '.growth',
    data: {
        nav: ['资金历史', '我的推广', '个人资料', '账号安全'],
        activenav: 0, //导航栏切换
        financetype: ['全部', '游戏', '充值', '提现'],
        financetypenum: 0, //切换资金类型
        cointypenum: -1, //切换币种
        coinhistory: { //资金历史 分页参数
            userId: 1,
            coin: '',
            type: '',
            p: 1,
            s: 10,
            list: []
        },
        showItem: 5,
        variable:'1',
        variablee:'1',
        variableee:'1',
        allpage: '', //资金历史总页面数
        spreadnum: 0, //我的推广/推广代码
        promotionnum: 1, //推广详情/用户推广
        promotionnumm: 'first', //推广详情/用户推广M!
        Quantity: 5,
        Pagenumber: 12,
        Afew: 5,
        location: '',
        old: null,//原密码
        newp: null,//新密码
        Confirmnew: null,//确认新密码
        changeunamenum: false,
        newusername:'',
        username:'',
        theuser:'',
        information:'',
        HPS: "HPS",
        ETH: "ETH",
        BTC: "BTC",
        HSR: "HSR",
        HAND: "HAND",
        HART: "HART",
        MOT: "MOT",
        isfalse: false,
        totall: null,
        totalll: null,
        ttotal: null,
        showuseravatar:false,
        avatar:'',
            brokerage0:'',
            brokerage1:'',
            brokerage2:'',
            brokerage3:'',
            brokerage4:'',
            brokerage5:'',
            brokerage6:'',
        myinvitation:{ //推广用户列表
            p:1, //当前页数
            s:8, //每页条数
            total:null,//总条数
            listarr:null, //存储各级总推广人数
            list:[], //当前页数返回数组
            showpage:5, //默认显示页数5个页
            // PageNumberr:0
        },
        usercommision:{ //推广详情
            p:1, //当前页数
            s:9, //每页条数
            total:null,//总条数
            list:[], //当前页数返回数组
            showpage:5, //默认显示页数5个页
            brokerage:null
        },
        loading:false
    },
    computed: {
        lastPagee: function () {
            var pag = [];
            if (this.Quantity < this.Afew) { //如果当前的激活的项 小于要显示的条数
                //总页数和要显示的条数那个大就显示多少条
                var i = Math.min(this.Afew, this.Pagenumber);
                while (i) {
                    pag.unshift(i--);
                }
            } else { //当前页数大于显示页数了
                var middle = this.Quantity - Math.floor(this.Afew / 2),//从哪里开始
                    i = this.Afew;
                if (middle > (this.Pagenumber - this.Afew)) {
                    middle = (this.Pagenumber - this.Afew) + 1
                }
                while (i--) {
                    pag.push(middle++);
                }
            }
            return pag
        },
        lastPage: function () {
            var pag = [];
            if (this.Quantity < this.Afew) { //如果当前的激活的项 小于要显示的条数
                //总页数和要显示的条数那个大就显示多少条
                var i = Math.min(this.Afew, this.Pagenumber);
                while (i) {
                    pag.unshift(i--);
                }
            } else { //当前页数大于显示页数了
                var middle = this.Quantity - Math.floor(this.Afew / 2),//从哪里开始
                    i = this.Afew;
                if (middle > (this.Pagenumber - this.Afew)) {
                    middle = (this.Pagenumber - this.Afew) + 1
                }
                while (i--) {
                    pag.push(middle++);
                }
            }
            return pag
        },
        pages: function () {
            var pag = [];
            if (this.coinhistory.p < this.showItem) { //如果当前的激活的项 小于要显示的条数
                //总页数和要显示的条数那个大就显示多少条
                var i = Math.min(this.showItem, this.allpage);
                while (i) {
                    pag.unshift(i--);
                }
            } else { //当前页数大于显示页数了
                var middle = this.coinhistory.p - Math.floor(this.showItem / 2),//从哪里开始
                    i = this.showItem;
                if (middle > (this.allpage - this.showItem)) {
                    middle = (this.allpage - this.showItem) + 1
                }
                while (i--) {
                    pag.push(middle++);
                }
            }
            return pag
        },
        invitationpages(){ //推广用户页数列表
            let pag=[]
            if(this.myinvitation.p<this.myinvitation.showpage){ //当前选择页数小于默认页数
                let i=Math.min(this.myinvitation.showpage,parseInt(this.myinvitation.total/8))
                // let i=Math.ceil(parseInt(this.myinvitation.total)/this.myinvitation.s)
                // let i=this.myinvitation.PageNumberr
                while(i){
                    pag.unshift(i--)
                }
            }else{//当前选择页数大于等于默认页数
                let middle=this.myinvitation.p-Math.floor(this.myinvitation.showpage/2) //设置起始页数
                let i=this.myinvitation.showpage 
                if(middle>(parseInt(this.myinvitation.PageNumberr)-this.myinvitation.showpage)){
                    middle=(parseInt(this.myinvitation.PageNumberr)-this.myinvitation.showpage)+1
                }
                while (i--) {
                    pag.push(middle++)
                }
            }  
            return pag
            
        },
        usercommisionpages(){ //推广详情页数列表
            let pag=[]
            if(this.usercommision.p <this.usercommision.showpage){ //当前选择页数小于默认页数
                let i=Math.min(this.usercommision.showpage,parseInt(this.usercommision.total))
                // let i=Math.ceil(parseInt(this.usercommision.total)/this.usercommision.s)
                while(i){
                    pag.unshift(i--)
                }
            }else{//当前选择页数大于等于默认页数
                let middle=this.usercommision.p -Math.floor(this.usercommision.showpage/2) //设置起始页数
                let i=this.usercommision.showpage 
                if(middle>(parseInt(this.usercommision.PageNumberr)-this.usercommision.showpage)){
                    middle=(parseInt(this.usercommision.PageNumberr)-this.usercommision.showpage)+1
                }
                while (i--) {
                    pag.push(middle++)
                }
            }  
            return pag
        },
        onUpload(e) {
            var formData = new FormData();
            formData.append('file', e.target.files[0]);
        },
    },
    created() {
        this.location = location.href.split('/')[0]+'//'+location.href.split('/')[2]+'/'
        if(location.href.indexOf('?')!=-1){
            let navnum=location.href.slice(location.href.lastIndexOf('=')+1)||0
            this.activenav=navnum
        }
        let params = {
            userId: this.coinhistory.userId,
            coin: this.coinhistory.coin,
            type: this.coinhistory.type,
            p: this.coinhistory.p,
            s: this.coinhistory.s
        }
        this.getcoinPostHistory(params)
        let params2={
            p:this.usercommision.p,
            s:this.usercommision.s
        }
        this.getCommision(params2)

        let params1={
            p:this.myinvitation.p,
            s:this.myinvitation.s
        }
        this.getInvitations(params1)
    },
    methods: {
        getCgera: function (num) {
            if(parseFloat(num)>10000){
                return parseFloat(parseFloat(num).toFixed(4))
            }else if(parseFloat(num)>100){
                return parseFloat(parseFloat(num).toFixed(6))
            }else if(parseFloat(num)>0){
                return parseFloat(parseFloat(num).toFixed(10))
            }else if(parseFloat(num)==0){
                return parseFloat(num).toFixed(0)
            }else{
                return parseFloat(num).toFixed(0)
            }
        },
        qingqion(){
            var cas=$('#image').cropper('getCroppedCanvas');
            var base64url=cas.toDataURL('image/jpeg');
            cas.toBlob(function (e) {
                // console.log(e);  //生成Blob的图片格式
            })
            let param = {base64url:base64url}
            axios.post('/user/profilePicture',param).then((res) => {
                if(res.data.code == 200){
                    this.avatar=res.data.data.avatar
                };
            });
        },
        uploadImage(){  // 上传图片
            var than=this
            let lang = this.getCookie("lang");
            var cas=$('#image').cropper('getCroppedCanvas');
            var base64url=cas.toDataURL('image/jpeg');
            cas.toBlob(function (e) {
                // console.log(e);  //生成Blob的图片格式
            })
            let param = {base64url:base64url};
                    axios.post('/user/profilePicture', param).then((res) => {
                        if(res.data.code == 200){
                            // console.log(res.data.data.avatar)
                            
                            var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                            document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                            var b='<div class="maskLayer"></div>'
                            document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                            document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                document.querySelector('.growth').removeChild(c)
                                document.querySelector('.growth').removeChild(d)
                                // window.location.reload();
                                // than.avatar=res.data.data.avatar
                                than.qingqion()
                                than.activenav = 2;
                                than.showuseravatar=false;
                            }
                            if (lang == "en_US") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="Uploaded successfully"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Your picture is uploaded successfully."
                            } else if (lang == "zh_TW") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="上傳成功"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您的頭像以上傳成功。"
                            } else {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="上传成功"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您的头像以上传成功。"
                            }
                        }else{
                            var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                            document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                            var b='<div class="maskLayer"></div>'
                            document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                            document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                document.querySelector('.growth').removeChild(c)
                                document.querySelector('.growth').removeChild(d)
                                // than.activenav = 2;
                                // than.showuseravatar=false;
                                // window.location.reload();
                            }
                            if (lang == "en_US") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="Picture is too big"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="You upload pictures too big, please change a smaller picture."
                            } else if (lang == "zh_TW") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="圖片太大"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您上傳圖片太大,請換張小一點的圖片。"
                            } else {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="图片太大"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您上传图片太大,请换张小一点的图片。"
                            }
                        }
                    })

        },
        inputImageee(){
            let lang = this.getCookie("lang");
            var uploadedImageURL;
            var $inputImage = $('#inputImage');
            var $image = $('#image');
            var options = {
                aspectRatio: 1/1,
                viewMode:1,
                dragMode:'none',
                preview: '.img-preview',
                responsive:false,
                autoCropArea:0.4,
                movable:false,
                cropBoxResizable:false,
                restore:false,
                zoomable:false,
                autoCrop:true,//显示裁剪框
                minContainerWidth: 500,
                minContainerHeight: 200,
              };
                // var fileSize =  document.getElementById('inputImage').files[0]; 
                // console.log(fileSize.size)
              
                // if(fileSize.size>380000){
                //     if(this.showuseravatar == true){
                //         this.showuseravatar = false;
                //         console.log(123132132)
                //     }else if(this.showuseravatar == false){
                //         var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                //         document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                //         var b='<div class="maskLayer"></div>'
                //         document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                //         document.getElementsByClassName("closeinfo")[0].onclick=function(){
                //             var c = document.getElementsByClassName('maskLayer')[0]  //移除元素
                //             var d = document.getElementsByClassName('errorMessage')[0] //移除元素
                //             document.querySelector('.growth').removeChild(c)
                //             document.querySelector('.growth').removeChild(d)
                            
                //         }
                //         if (lang == "en_US") {
                //             document.getElementsByClassName('errorMessageTop')[0].innerHTML="Uploaded successfully"
                //             document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Your picture is uploaded successfully."
                //         } else if (lang == "zh_TW") {
                //             document.getElementsByClassName('errorMessageTop')[0].innerHTML="上傳成功"
                //             document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您的頭像以上傳成功。"
                //         } else {
                //             document.getElementsByClassName('errorMessageTop')[0].innerHTML="图片太大"
                //             document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您上传图片太大。"
                //         }
                //         return
                //     }
                // }
                var $inputImage = $('#inputImage');

                if (URL) {
                  $inputImage.change(function () {
                    var files = this.files;
                    var file;

                    if (!$image.data('cropper')) {
                      return;
                    }

                    if (files && files.length) {
                      file = files[0];

                      if (/^image\/\w+$/.test(file.type)) {
                        uploadedImageName = file.name;
                        uploadedImageType = file.type;
                        if (uploadedImageURL) {
                          URL.revokeObjectURL(uploadedImageURL);
                        }
                        uploadedImageURL = URL.createObjectURL(file);
                        $image.cropper('destroy').attr('src', uploadedImageURL).cropper(options);
                        $inputImage.val('');
                      } else {
                        var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                        document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                        var b='<div class="maskLayer"></div>'
                        document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                        document.getElementsByClassName("closeinfo")[0].onclick=function(){
                            var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                            var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                            document.querySelector('.growth').removeChild(c)
                            document.querySelector('.growth').removeChild(d)
                            // window.location.reload();
                            // this.navclick(2);
                            // this.returnn();
                        }
                        if (lang == "en_US") {
                            document.getElementsByClassName('errorMessageTop')[0].innerHTML="Not pictures"
                            document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Please select picture upload."
                        } else if (lang == "zh_TW") {
                            document.getElementsByClassName('errorMessageTop')[0].innerHTML="不是圖片"
                            document.getElementsByClassName('errorMessageBottom')[0].innerHTML="請選擇圖片上傳。"
                        } else {
                            document.getElementsByClassName('errorMessageTop')[0].innerHTML="不是图片"
                            document.getElementsByClassName('errorMessageBottom')[0].innerHTML="请选择图片上传。"
                        }
                        return
                      }
                    }
                  });
                } else {
                  $inputImage.prop('disabled', true).parent().addClass('disabled');
                }
        },
        returnn(){
            this.showuseravatar=false;
        },
        navclick(index) { //侧边栏导航
            this.activenav = index;
            if (this.activenav == 1){
                let params2={
                    p:this.usercommision.p,
                    s:this.usercommision.s
                }
                this.getCommision(params2)
                let params={
                    p:this.myinvitation.p,
                    s:this.myinvitation.s
                }
                this.getInvitations(params)
                this.$refs.usernav.style.height = "953px";
            }else {
                this.spreadnum = 0;
                this.$refs.usernav.style.height = "740px";
            }
        },
        changefinancetype(index) { //资金类型
            this.financetypenum = index
            this.coinhistory.p = 1
            if(index==0){
                this.coinhistory.type=''
            }else if(index==1){
                this.coinhistory.type='game'
            }else if(index==2){
                this.coinhistory.type='deposit'
            }else if(index==3){
                this.coinhistory.type='withdraw'
            }else if(index==4){
                this.coinhistory.type='transfer'
            }else if(index==5){
                this.coinhistory.type='ag'
            }else if(index==6){
                this.coinhistory.type='commission'
            }else if(index==7){
                this.coinhistory.type='others'
            }else if(index==8){
                this.coinhistory.type='sb'
            }
            let params = {
                userId: this.coinhistory.userId,
                coin: this.coinhistory.coin,
                type: this.coinhistory.type,
                p: this.coinhistory.p,
                s: this.coinhistory.s
            }
            this.getcoinPostHistory(params) 
        },
        changecointype(coin, index) { //切换币种
            this.cointypenum = index
            this.coinhistory.coin = coin
            this.coinhistory.p = 1
            let params = {
                userId: this.coinhistory.userId,
                coin: this.coinhistory.coin,
                type: this.coinhistory.type,
                p: this.coinhistory.p,
                s: this.coinhistory.s
            }
            this.getcoinPostHistory(params)
        },
        goto(index) { //分页跳转
            this.coinhistory.p = index;
            let params = {
                userId: this.coinhistory.userId,
                coin: this.coinhistory.coin,
                type: this.coinhistory.type,
                p: this.coinhistory.p,
                s: this.coinhistory.s
            }
            this.getcoinPostHistory(params)
        },
        gotoo(index) { //跳转
            // console.log(this.totall)
            if(index>this.totall){
                index=this.totall;
                this.variable=index;
            }else if(index<1){
                index=1
                this.variable=index;
            }
            this.coinhistory.p = index;
            let params = {
                userId: this.coinhistory.userId,
                coin: this.coinhistory.coin,
                type: this.coinhistory.type,
                p: this.coinhistory.p,
                s: this.coinhistory.s
            }
            this.getcoinPostHistory(params)
        },
        tguango(index) { //推广详情跳转
            // console.log(Math.ceil(this.totalll))
            if(index>Math.ceil(this.totalll)){
                index=Math.ceil(this.totalll);
                this.variablee=index;
            }else if(index<1){
                index=1
                this.variablee=index;
            }
            this.usercommision.p = index;
            let params2={
                p:this.usercommision.p,
                s:this.usercommision.s
            }
            this.getCommision(params2)
        },
        changespread(index) { //我的推广
            this.spreadnum = index;
            if (this.spreadnum == 1)
                this.$refs.spreadnav.style.height = "1053px"
            else
                this.$refs.spreadnav.style.height = "160px"
        },
        changepromotion(index) { //推广详情
            this.promotionnum = index;
            if(index===1){
                let params2={
                    p:this.usercommision.p,
                    s:this.usercommision.s
                }
                this.getCommision(params2)
            }else if(index===0){
                let params={
                    p:this.myinvitation.p,
                    s:this.myinvitation.s
                }
                this.getInvitations(params)
            }
        },
        changepromotionn(index) { //推广详情M1
            this.promotionnumm = index;
            this.myinvitation.p=1
            this.myinvitation.total=null
            this.myinvitation.list=[]
            this.dealInvitations(this.promotionnumm,this.myinvitation.p,this.myinvitation.s)
        },
        gotoPromotion(index) {  //推广分页跳转
            // console.log(index)
            // if (index == this.Quantity)
            //     return;
            // this.Quantity = index;
            this.usercommision.p=index
            let params2={
                p:this.usercommision.p,
                s:this.usercommision.s
            }
            this.getCommision(params2)
        },
        gotoPromotiont(index) {  //推广用户分页跳转
            if(index>this.myinvitation.PageNumberr){
                index=this.myinvitation.PageNumberr
                this.variableee=index;
            }else if(index<1){
                index=1
                this.variableee=index;
            }
            this.getcurrentInvitations(index)
        },
        Home(){//资金首页
            this.coinhistory.p = 1;
            let params = {
                userId: this.coinhistory.userId,
                coin: this.coinhistory.coin,
                type: this.coinhistory.type,
                p: this.coinhistory.p,
                s: this.coinhistory.s
            }
            this.getcoinPostHistory(params)
        },
        lastPage(){//资金尾页
            index=this.totall;
            this.variable=index;
            this.variable=index;
            this.coinhistory.p = index;
            let params = {
                userId: this.coinhistory.userId,
                coin: this.coinhistory.coin,
                type: this.coinhistory.type,
                p: this.coinhistory.p,
                s: this.coinhistory.s
            }
            this.getcoinPostHistory(params)
        },
        Homet(){//推广首页
            this.usercommision.p = 1;

                let params2={
                    p:this.usercommision.p,
                    s:this.usercommision.s
                }
                this.getCommision(params2)

        },
        lastPaget(){//推广尾页
            index=Math.ceil(this.totalll);
            this.usercommision.p = index;
                let params2={
                    p:this.usercommision.p,
                    s:this.usercommision.s
                }
                this.getCommision(params2)
        },
        Homett(){//推广用户首页
            this.getcurrentInvitations(1)
        },
        lastPagett(){//推广用户尾页
            this.getcurrentInvitations(this.myinvitation.PageNumberr)
        },
        getTime: function (time) { //计算时间
            // var timeStr = time + 28800000;
            if(!time){
                return ''
            }
            var timeStr = time;
            var t = new Date(timeStr) 
            function charLeftAll(n) {
                if (n < 10) return "0" + n;
                else return n;
            }
            return t.getFullYear() + '-' + charLeftAll((t.getMonth() + 1)) + '-' + charLeftAll(t.getDate()) + '  ' +
                charLeftAll(t.getHours()) + ':' + charLeftAll(t.getMinutes()) + ':' + charLeftAll(t.getSeconds())
        },
        InterceptionMailbox: function (time) { //截取邮箱
            var str=time;
            var arr=str.split(" ");
            return arr[3]
        },
        getcoinPostHistory(obj = null) { //获取资金历史
            axios.post('/coin/coinPostHistory', obj).then((res) => {
                this.coinhistory.list = this.filtercoinhistorylist(res.data.data.list,res.data.data.rate)
                this.allpage = res.data.data.pages
                this.totall=res.data.data.pages
            })
        },
        filtercoinhistorylist(arr1,arr2){ //过滤资金历史数组
            if(arr1.length){
                arr1.forEach(ele => {
                    arr2.forEach(ele2 => {
                        if(ele2){
                            if(ele.type=='TRANSFER TO AG'&&`ag-rate-${ele.coin}`==ele2.dictKey){
                                let dictValue=ele2.dictValue?parseInt(ele2.dictValue):1
                                ele.agcompute=parseFloat(ele.amount)*dictValue
                            }else if(ele.type=='TRANSFER FROM AG'&&`ag-rate-${ele.coin}`==ele2.dictKey){
                                let dictValue=ele2.dictValue?parseInt(ele2.dictValue):1
                                ele.agcompute=parseFloat(ele.amount)*dictValue
                            }else if(ele.type=='TRANSFER TO SB'&&`ag-rate-${ele.coin}`==ele2.dictKey){
                                let dictValue=ele2.dictValue?parseInt(ele2.dictValue):1
                                ele.sbcompute=parseFloat(ele.amount)*dictValue
                            }else if(ele.type=='TRANSFER FROM SB'&&`ag-rate-${ele.coin}`==ele2.dictKey){
                                let dictValue=ele2.dictValue?parseInt(ele2.dictValue):1
                                ele.sbcompute=parseFloat(ele.amount)*dictValue
                            }
                        }
                    })
                })
                return arr1
            }else{
                return []
            }
        },
        webhref(imgstr){ // 获取推广代码
            // let userid = this.locaId ? this.locaId : this.personal.id
            let userid = window.localStorage.getItem('ID')
            let html = `<a href="${this.location}?ref=${userid}"><img src="${imgstr}"/></a>`
            return html
        },
        onCopy(){ //复制推广链接
            this.$refs.inputtext.select();
            document.execCommand("copy");
        }, 
        changeusername(){ //更改信息
            this.changeunamenum=!this.changeunamenum;
            let param = {nickname:this.newusername};
            let lang = this.getCookie("lang");
            let reg =  /^[\u4e00-\u9fffa-zA-Z0-9|\S*]{1,8}$/
            if(!this.changeunamenum){
                if(this.newusername==""){
                    var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                    document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                    var b='<div class="maskLayer"></div>'
                    document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                    document.getElementsByClassName("closeinfo")[0].onclick=function(){
                        var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                        var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                        document.querySelector('.growth').removeChild(c)
                        document.querySelector('.growth').removeChild(d)
                    }
                    if (lang == "en_US") {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="Modify Error"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="The nickname can not be empty."
                    } else if (lang == "zh_TW") {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失敗"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="用戶名不能為空"
                    } else {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失败"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="用户名不能为空"
                    }
                }else if(!reg.test(this.newusername)){
                    var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                    document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                    var b='<div class="maskLayer"></div>'
                    document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                    document.getElementsByClassName("closeinfo")[0].onclick=function(){
                        var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                        var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                        document.querySelector('.growth').removeChild(c)
                        document.querySelector('.growth').removeChild(d)
                    }
                    if (lang == "en_US") {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="Modify Error"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="The length can not exceed 8 characters and no empty characters."
                    } else if (lang == "zh_TW") {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失敗"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="長度不能超過8個字符且不能有空字符。"
                    } else {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失败"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="长度不能超过8个字符且不能有空字符。"
                    }
                }else{
                    axios.post('/user/updatebasicinfo', param).then((res) => {
                        if(res.data.code == 200){
                            this.username=res.data.data.nickname
                            var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                            document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                            var b='<div class="maskLayer"></div>'
                            document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                            document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                document.querySelector('.growth').removeChild(c)
                                document.querySelector('.growth').removeChild(d)
                            }
                            if (lang == "en_US") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="Modify Success"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Your nickname has been modified successfully."
                            } else if (lang == "zh_TW") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改成功"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您的用護名修改成功。"
                            } else {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改成功"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您的用户名修改成功。"
                            }
                            this.newusername=""
                        }
                    })
                } 
            }
        },
        getCookie(cookiename) { //获取cookie
            var arr,
              reg = new RegExp("(^| )" + cookiename + "=([^;]*)(;|$)");
            if ((arr = document.cookie.match(reg))) {
              return unescape(arr[2]);
            } else {
              return null;
            }
        },
        updatepassword() { //修改密码
            let lang = this.getCookie("lang");
            let that = this,old=null;
            if(this.$refs.oldpassword){
                old = this.$refs.oldpassword.value
            }
            if(old==""){
                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                var b='<div class="maskLayer"></div>'
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                    document.querySelector('.growth').removeChild(c)
                    document.querySelector('.growth').removeChild(d)
                }
                if (lang == "en_US") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Change Failed"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Please enter verification code"
                } else if (lang == "zh_TW") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失敗"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="請輸入驗證碼"
                } else {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失败"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="请输入验证码"
                }
                return; 
            }
            if(document.getElementsByClassName("sendcodeone")[0].value.length!=6){
                var a= '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                var b='<div class="maskLayer"></div>'
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                    var c= document.getElementsByClassName('maskLayer')[0] //移除元素
                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                    document.querySelector('.growth').removeChild(c)
                    document.querySelector('.growth').removeChild(d)
                }
                if (lang == "en_US") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Change Failed"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Invalid verification code format"
                } else if (lang == "zh_TW") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失敗"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="驗證碼格式有誤"
                } else {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失败"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="验证码格式有误"
                }
                return
            }
            let newp = this.$refs.newpassword.value; //旧密码
            let Confirmnew = this.$refs.Confirmnewpassword.value; //确认新密码
            let UID = (this.locaId = JSON.parse(window.localStorage.getItem("ID")));
            if (newp == "" || Confirmnew == "") {
                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                    document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                    var b='<div class="maskLayer"></div>'
                    document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                    document.getElementsByClassName("closeinfo")[0].onclick=function(){
                        var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                        var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                        document.querySelector('.growth').removeChild(c)
                        document.querySelector('.growth').removeChild(d)
                 }
                if (lang == "en_US") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Change Failed"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Password cannot be blank Please re-enter"
                } else if (lang == "zh_TW") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失敗"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密碼不能為空請重新輸入。"
                } else {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失败"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密码不能为空请重新输入。"
                }
                return;
            }
            if(newp==Confirmnew){
                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                var b='<div class="maskLayer"></div>'
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                    document.querySelector('.growth').removeChild(c)
                    document.querySelector('.growth').removeChild(d)
             }
                if (lang == "en_US") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="fail to edit"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="The new password is the same as the original password."
                } else if (lang == "zh_TW") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失敗"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="新密碼與原密碼相同。"
                } else {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失败"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="新密码与原密码相同。"
                }
                this.$refs.newpassword.value=''
                this.$refs.Confirmnewpassword.value=''
                return;
            }
            if(Confirmnew.length<6){
                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                var b='<div class="maskLayer"></div>'
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                    document.querySelector('.growth').removeChild(c)
                    document.querySelector('.growth').removeChild(d)
                }
                if (lang == "en_US") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Change Failed"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Password length cannot be less than 6"
                } else if (lang == "zh_TW") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失敗"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密碼長度不能小於6"
                } else {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改失败"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密码长度不能小于6"
                }
                return; 
            }
            let params = {
                password: newp,
                newPassword: Confirmnew,
                checkCode:parseFloat(old)
            };
            axios.post("/user/updateUserPassword", params).then(res => {
              if (res.data.code == 200) {
                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                var b='<div class="maskLayer"></div>'
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                    document.querySelector('.growth').removeChild(c)
                    document.querySelector('.growth').removeChild(d)
                }
                    if (lang == "en_US") {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="Successfully modified"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Your password was successfully modified."
                    } else if (lang == "zh_TW") {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改成功"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您的密碼修改成功。"
                    } else if (lang == "zh_TW") {
                    } else {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="修改成功"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="您的密码修改成功。"
                    }
                    // this.old = "";
                    this.newp = "";
                    this.Confirmnew = "";
                    // location.reload()
                    return;
                } else if (res.data.code == -10003) {
                    var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                var b='<div class="maskLayer"></div>'
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                    document.querySelector('.growth').removeChild(c)
                    document.querySelector('.growth').removeChild(d)
                }
                    if (lang == "en_US") {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="Wrong Password"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="The original password is wrong please re-enter"
                    } else if (lang == "zh_TW") {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="密碼錯誤"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="原密碼錯誤請重新輸入"
                    } else {
                        document.getElementsByClassName('errorMessageTop')[0].innerHTML="密码错误"
                        document.getElementsByClassName('errorMessageBottom')[0].innerHTML="原密码错误请重新输入"
                    }
                    // this.old = "";
                    this.newp = "";
                    this.Confirmnew = "";
                    return;
              }else if(res.data.code == -10007){
                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                var b='<div class="maskLayer"></div>'
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                    document.querySelector('.growth').removeChild(c)
                    document.querySelector('.growth').removeChild(d)
                }
                if (lang == "en_US") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Wrong Password"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Verification code expired"
                } else if (lang == "zh_TW") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="驗證碼錯誤"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="驗證碼過期"
                } else {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="验证码错误"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="验证码过期"
                }
                // this.old = "";
                this.newp = "";
                this.Confirmnew = "";
                return;
              }else if(res.data.code == -10009){
                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',a)
                var b='<div class="maskLayer"></div>'
                document.querySelector('.growth').insertAdjacentHTML('afterBegin',b)
                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                    document.querySelector('.growth').removeChild(c)
                    document.querySelector('.growth').removeChild(d)
                }
                if (lang == "en_US") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Wrong Password"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Incorrect verification code"
                } else if (lang == "zh_TW") {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="驗證碼錯誤"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="驗證碼輸入錯誤"
                } else {
                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="验证码错误"
                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="验证码输入错误"
                }
                // this.old = "";
                this.newp = "";
                this.Confirmnew = "";
                return;
              }
            });
        },
        filterStr(str){ //转换小写
            return str.toLowerCase()
        },
        sendcode() { //发送验证码
            let lang = this.getCookie("lang");
            let params = {
                type: 7,
                sendTo: document.getElementsByClassName("signone")[0].innerText
                };
                axios.post("/comm/mail/send", params).then(res => {  
            });
            this.isfalse = true;
            let time = 60;
            document.getElementsByClassName('modifybtn')[0].style.background="#909090"
            let that=this
            let sendtime=setInterval(function(){
                time-=1
                document.getElementsByClassName('modifybtn')[0].innerHTML=time +"s"
                if(time==0){
                    if (lang == "en_US") {
                        document.getElementsByClassName('modifybtn')[0].innerHTML="send code"
                    } else if (lang == "zh_TW") {
                        document.getElementsByClassName('modifybtn')[0].innerHTML="發送"
                    } else {
                        document.getElementsByClassName('modifybtn')[0].innerHTML="发送"
                    }
                    document.getElementsByClassName('modifybtn')[0].style.background="#CF1132"
                    that.isfalse=false
                    clearInterval(sendtime)
                }
            },1000)
        },
        getInvitations(obj=null){ //获取推广用户
            axios.post('/user/myinvitation',obj).then((res) => {
                if(res.data.code==200){
                    // this.myinvitation.list=res.data.data.list
                    // this.myinvitation.total=res.data.data.total||0
                    // this.ttotal=res.data.data.total/9
                    // this.myinvitation.PageNumberr= res.data.data.pages
                    // this.fifth.list=res.data.data.list[0].fifth
                    // this.fifth.total=res.data.data.list[0].fifth.total
                    this.myinvitation.listarr=res.data.data
                    this.dealInvitations(this.promotionnumm,this.myinvitation.p,this.myinvitation.s)
                }
            })
        },
        dealInvitations(type,start,pagesize){ //分页筛选推广用户
            this.myinvitation.total=this.myinvitation.listarr[type].length
            this.myinvitation.ttotall=this.myinvitation.listarr[type].length/9
            
            this.myinvitation.PageNumberr=Math.ceil(this.myinvitation.total/this.myinvitation.s)||0
            // console.log(this.myinvitation.total)
            this.myinvitation.list=this.myinvitation.listarr[type].slice((start-1)*pagesize,(start-1)*pagesize+pagesize)
        },
        getcurrentInvitations(num){ //分页获取推广用户
            this.myinvitation.p=num
            this.dealInvitations(this.promotionnumm,this.myinvitation.p,this.myinvitation.s)
        },
        getCommision(obj=null){ //获取推广详情
            axios.post('/user/getCommision',obj).then((res) => {
                if(res.data.code==200){

                   this.usercommision.list=res.data.data.list
                   this.usercommision.total=res.data.data.total
                   this.totalll=res.data.data.total/9
                   this.usercommision.PageNumberr= res.data.data.pages

                   this.usercommision.brokerage=res.data.data.data2
                   this.brokerage0=this.usercommision.brokerage.HPS
                   this.brokerage1=this.usercommision.brokerage.ETH
                   this.brokerage2=this.usercommision.brokerage.BTC
                   this.brokerage3=this.usercommision.brokerage.HSR
                   this.brokerage4=this.usercommision.brokerage.HAND 
                   this.brokerage5=this.usercommision.brokerage.HART
                   this.brokerage6=this.usercommision.brokerage.MOT
                }
            })
        },
        getcurrentCommision(num){ //分页获取推广详情
            this.usercommision.p=num
            let params2={
                p:this.usercommision.p,
                s:this.usercommision.s
            }
            this.getCommision(params2)
        }
    },
    mounted(){
        this.loading=true
    }
})